package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}
type AppConfig struct {
	Mysql
	Redis
}

var AppCfg AppConfig

func InitConfig() {
	viper.SetConfigFile("../appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("读取文件失败")
	}
	err = viper.Unmarshal(&AppCfg)
	if err != nil {
		panic("文件解析失败")
	}
	fmt.Println("配置文件加载成功")
}
